import React, {Component} from 'React';
import Nav from './Nav';
import Filter from './Filter';
import Product from './Product';

export default class Parent extends Component {
    constructor() {
        super()
        this.state = {
            info: [],
        }
    }
    // 多选-匹配
    handleChange(con){
        // this.props.history.push(`${this.props.location.pathname}`);
        console.log(con); //此处con即表示接收到的多选框数据
        console.log(this.props.history.search)
        if(this.state.info.indexOf(con)){
            this.state.info.push(con);
        }
        this.setState({info: this.state.info[this.state.info.length-1]},function(){
            // console.log(this.props.match.params.)
            this.props.history.push(`/showProduct/${this.props.match.params.brand}/${this.props.match.params.classify}/${this.props.match.params.sortGoods}/${this.state.info}`);
        })
        console.log(this.props)
    }

    //输入价格
    inputChange(con){
        // this.props.history.push(`${this.props.location.pathname}`);
        console.log('bbb',con); //此处con即表示接收到的多选框数据
        console.log(this.props.history.search)
        if(this.state.priceArr.indexOf(con)){
            this.state.priceArr.push(con);
        }
        this.setState({priceArr: this.state.priceArr[this.state.priceArr.length-1]},function(){
            // console.log(this.props.match.params.)
            this.props.history.push(`/showProduct/${this.props.match.params.brand}/${this.props.match.params.classify}/${this.props.match.params.sortGoods}/${this.state.check}`);
        })
        console.log('6666',this.props)
    }

    // componentDidMount(){
        // console.log(this.props.match.params)
    // }
    render() {
        return (
            <div>
                <Nav
                brand     = {this.props.match.params.brand}
                classify  = {this.props.match.params.classify}
                sortGoods = {this.props.match.params.sortGoods}
                check     = {this.props.match.params.check}
                />
                <Filter listPrice={this.state.priceArr}
                brand     = {this.props.match.params.brand}
                classify  = {this.props.match.params.classify}
                sortGoods = {this.props.match.params.sortGoods}
                check     = {this.props.match.params.check}

                onChange = { this.handleChange.bind(this)}
                />{/* onClick = { this.handleClick.bind(this)}*/}
                <div className="product_box" list={this.state.info}>
                    <Product
                    brand     = {this.props.match.params.brand}
                    classify  = {this.props.match.params.classify}
                    sortGoods = {this.props.match.params.sortGoods}
                    check     = {this.props.match.params.check}
                    />

                </div>
            </div>
        )
    }
}